home *** CD-ROM | disk | FTP | other *** search
-
- Listing 2. LODSW Method of Finding Terminator Zero
- string DB "This is a string",0
- .....
- cld ; clear direction
- mov si,offset string ; load offset
- mov cx,si ; get offset into counter
- repeat:
- lodsw ; load word from string
- test ah,al ; zero yet?
- jz end_repeat ; if so exit and adjust
- lodsw ; load word from string
- test ah,al ; zero yet?
- jz end_repeat ; if so exit and adjust
- lodsw ; load word from string
- test ah,al ; zero yet?
- jnz repeat ; if not repeat
- end_repeat:
- sub si,cx ; get unadjusted count
- mov cx,si ; move to return register
- cmp al,0 ; is lead byte zero?
- jz adj_two ; if so adjust back two
- dec cx ; else adjust back one
- jmp adj_end ; then exit
- adj_two:
- sub cx,2 ; adjust back two
- adj_end:
- .....
-